<?php
/**
 * 后台控制器基类
 */
declare(strict_types=1);

namespace App\Controller\Admin;

use App\Controller\AbstractController;
use App\Helper\ApiHelper;
use App\Helper\CurdTrait;

abstract class BaseController extends AbstractController
{
    /**
     * 模型名称
     * @var string $model
     */
    public $model = '';

    /**
     * CURD
     */
    use CurdTrait;

    /**
     * 成功返回
     * @param null|mixed $data
     * @param int|null $count
     * @return array
     */
    public static function genSuccessData($data = null, ?int $count = null): array
    {
        return ApiHelper::genSuccessData($data, $count);
    }

    /**
     * 失败返回
     * @param string|null $msg
     * @param int|mixed $code
     * @return array
     */
    public static function genErrorData(?string $msg = null, $code = 1): array
    {
        return ApiHelper::genErrorData($msg, $code);
    }
}
